home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-08-25 | 1.6 KB | 71 lines | [TEXT/MMCC] |
- /*
- File: SplashWindow.cp
-
- Contains: a simple splash screen window
-
- Written by: Dave Falkenburg
-
- Copyright: © 1993-94 by Dave Falkenburg, all rights reserved.
-
- Change History (most recent first):
-
- To Do: Add tools to the palette
- */
-
- #include <ToolUtils.h>
- #include <Resources.h>
- #include "AppLib.h"
- #include "SplashWindow.h"
-
-
- TSplashWindow::TSplashWindow()
- {
- this->CreateWindow(kNormalWindow);
- }
-
-
- TSplashWindow::~TSplashWindow()
- {
- this->Close();
- }
-
-
- WindowPtr
- TSplashWindow::MakeNewWindow(WindowPtr behindWindow)
- {
- PicHandle splashPicture = GetPicture(kSplashPictureID);
- WindowPtr splashWindow;
- GrafPtr oldPort;
-
- GetPort(&oldPort);
-
- if (splashPicture)
- {
- Rect r = (**splashPicture).picFrame;
- Rect windowRect;
-
- // normalize the rectangle
- OffsetRect(&r,-r.left,-r.top);
-
- windowRect = r;
- // center it on the main screen
- OffsetRect(&windowRect,((qd.screenBits.bounds.right-r.right) >> 1),((qd.screenBits.bounds.bottom-r.bottom) >> 1));
-
- if (gHasColorQuickdraw)
- splashWindow = NewWindow(nil,&windowRect,"\p",false,dBoxProc,behindWindow,false,(long) this);
- else
- splashWindow = NewCWindow(nil,&windowRect,"\p",false,dBoxProc,behindWindow,false,(long) this);
-
- DetachResource((Handle) splashPicture); // need to do so we don’t botch the resource map after closing
- SetWindowPic(splashWindow,splashPicture); // in case an Alert comes up
- ShowWindow(splashWindow);
- SetPort(splashWindow);
- BeginUpdate(splashWindow); // avoid a flashing update event later
- DrawPicture(splashPicture,&r);
- EndUpdate(splashWindow); // avoid a flashing update event later
- }
-
- SetPort(oldPort);
- return splashWindow;
- }
-